home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / tests / focus.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  17.2 KB  |  631 lines  |  [TEXT/ALFA]

  1. # This file is a Tcl script to test out the "focus" command and the
  2. # other procedures in the file tkFocus.c.  It is organized in the
  3. # standard fashion for Tcl tests.
  4. #
  5. # Copyright (c) 1994-1996 Sun Microsystems, Inc.
  6. #
  7. # See the file "license.terms" for information on usage and redistribution
  8. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9. #
  10. # SCCS: @(#) focus.test 1.24 97/08/11 09:39:34
  11.  
  12. if {$tcl_platform(platform) != "unix"} {
  13.     return
  14. }
  15.  
  16. if {[info procs test] != "test"} {
  17.     source defs
  18. }
  19.  
  20. eval destroy [winfo children .]
  21. wm geometry . {}
  22. raise .
  23.  
  24. button .b -text .b -relief raised -bd 2
  25. pack .b
  26.  
  27. proc focusSetup {} {
  28.     catch {destroy .t}
  29.     toplevel .t
  30.     wm geom .t +0+0
  31.     foreach i {b1 b2 b3 b4} {
  32.     button .t.$i -text .t.$i -relief raised -bd 2
  33.     pack .t.$i
  34.     }
  35.     tkwait visibility .t.b4
  36. }
  37. proc focusSetupAlt {} {
  38.     global env
  39.     catch {destroy .alt}
  40.     toplevel .alt -screen $env(TK_ALT_DISPLAY)
  41.     wm withdraw .alt
  42.     foreach i {a b c d} {
  43.     button .alt.$i -text .alt.$i -relief raised -bd 2
  44.     pack .alt.$i
  45.     }
  46.     tkwait visibility .alt.d
  47. }
  48.  
  49. # Make sure the window manager knows who has focus
  50. fixfocus
  51.  
  52. # The following procedure ensures that there is no input focus
  53. # in this application.  It does it by arranging for another
  54. # application to grab the focus.  The "after" and "update" stuff
  55. # is needed to wait long enough for pending actions to get through
  56. # the X server and possibly also the window manager.
  57.  
  58. setupbg
  59. proc focusClear {} {
  60.     global x;
  61.     after 200 {set x 1}
  62.     tkwait variable x
  63.     dobg {focus -force .; update}
  64.     update
  65. }
  66.  
  67. focusSetup
  68. set altDisplay [info exists env(TK_ALT_DISPLAY)]
  69. if $altDisplay {
  70.     focusSetupAlt
  71. }
  72. update
  73.  
  74. bind all <FocusIn> {
  75.     append focusInfo "in %W %d\n"
  76. }
  77. bind all <FocusOut> {
  78.     append focusInfo "out %W %d\n"
  79. }
  80. bind all <KeyPress> {
  81.     append focusInfo "press %W %K"
  82. }
  83.  
  84. test focus-1.1 {Tk_FocusCmd procedure} {
  85.     focusClear
  86.     focus
  87. } {}
  88. if $altDisplay {
  89.     test focus-1.2 {Tk_FocusCmd procedure} {
  90.     focus .alt.b
  91.     focus
  92.     } {}
  93. }
  94. test focus-1.3 {Tk_FocusCmd procedure} {
  95.     focusClear
  96.     focus .t.b3
  97.     focus
  98. } {}
  99. test focus-1.4 {Tk_FocusCmd procedure} {
  100.     list [catch {focus ""} msg] $msg
  101. } {0 {}}
  102. test focus-1.5 {Tk_FocusCmd procedure} {
  103.     focusClear
  104.     focus -force .t
  105.     focus .t.b3
  106.     focus
  107. } {.t.b3}
  108. test focus-1.6 {Tk_FocusCmd procedure} {
  109.     list [catch {focus .gorp} msg] $msg
  110. } {1 {bad window path name ".gorp"}}
  111. test focus-1.7 {Tk_FocusCmd procedure} {
  112.     list [catch {focus .gorp a} msg] $msg
  113. } {1 {bad option ".gorp": must be -displayof, -force, or -lastfor}}
  114. test focus-1.8 {Tk_FocusCmd procedure, focussing on dead window} {
  115.     toplevel .t2
  116.     wm geom .t2 +10+10
  117.     frame .t2.f -width 200 -height 100 -bd 2 -relief raised
  118.     frame .t2.f2 -width 200 -height 100 -bd 2 -relief raised
  119.     pack .t2.f .t2.f2
  120.     bind .t2.f <Destroy> {focus .t2.f}
  121.     bind .t2.f2 <Destroy> {focus .t2}
  122.     focus -force .t2.f2
  123.     tkwait visibility .t2.f2
  124.     update
  125.     set x [focus]
  126.     destroy .t2.f2
  127.     lappend x [focus]
  128.     destroy .t2.f
  129.     lappend x [focus]
  130.     destroy .t2
  131.     set x
  132. } {.t2.f2 .t2 .t2}
  133. test focus-1.9 {Tk_FocusCmd procedure, -displayof option} {
  134.     list [catch {focus -displayof} msg] $msg
  135. } {1 {wrong # args: should be "focus -displayof window"}}
  136. test focus-1.10 {Tk_FocusCmd procedure, -displayof option} {
  137.     list [catch {focus -displayof a b} msg] $msg
  138. } {1 {wrong # args: should be "focus -displayof window"}}
  139. test focus-1.11 {Tk_FocusCmd procedure, -displayof option} {
  140.     list [catch {focus -displayof .lousy} msg] $msg
  141. } {1 {bad window path name ".lousy"}}
  142. test focus-1.12 {Tk_FocusCmd procedure, -displayof option} {
  143.     focusClear
  144.     focus .t
  145.     focus -displayof .t.b3
  146. } {}
  147. test focus-1.13 {Tk_FocusCmd procedure, -displayof option} {
  148.     focusClear
  149.     focus -force .t
  150.     focus -displayof .t.b3
  151. } {.t}
  152. if $altDisplay {
  153.     test focus-1.14 {Tk_FocusCmd procedure, -displayof option} {
  154.     focus -force .alt.c
  155.     focus -displayof .alt
  156.     } {.alt.c}
  157. }
  158. test focus-1.15 {Tk_FocusCmd procedure, -force option} {
  159.     list [catch {focus -force} msg] $msg
  160. } {1 {wrong # args: should be "focus -force window"}}
  161. test focus-1.16 {Tk_FocusCmd procedure, -force option} {
  162.     list [catch {focus -force a b} msg] $msg
  163. } {1 {wrong # args: should be "focus -force window"}}
  164. test focus-1.17 {Tk_FocusCmd procedure, -force option} {
  165.     list [catch {focus -force foo} msg] $msg
  166. } {1 {bad window path name "foo"}}
  167. test focus-1.18 {Tk_FocusCmd procedure, -force option} {
  168.     list [catch {focus -force ""} msg] $msg
  169. } {0 {}}
  170. test focus-1.19 {Tk_FocusCmd procedure, -force option} {
  171.     focusClear
  172.     focus .t.b1
  173.     set x  [list [focus]]
  174.     focus -force .t.b1
  175.     lappend x [focus]
  176. } {{} .t.b1}
  177. test focus-1.20 {Tk_FocusCmd procedure, -lastfor option} {
  178.     list [catch {focus -lastfor} msg] $msg
  179. } {1 {wrong # args: should be "focus -lastfor window"}}
  180. test focus-1.21 {Tk_FocusCmd procedure, -lastfor option} {
  181.     list [catch {focus -lastfor 1 2} msg] $msg
  182. } {1 {wrong # args: should be "focus -lastfor window"}}
  183. test focus-1.22 {Tk_FocusCmd procedure, -lastfor option} {
  184.     list [catch {focus -lastfor who_knows?} msg] $msg
  185. } {1 {bad window path name "who_knows?"}}
  186. test focus-1.23 {Tk_FocusCmd procedure, -lastfor option} {
  187.     focus .b
  188.     focus .t.b1
  189.     list [focus -lastfor .] [focus -lastfor .t.b3]
  190. } {.b .t.b1}
  191. test focus-1.24 {Tk_FocusCmd procedure, -lastfor option} {
  192.     destroy .t
  193.     focusSetup
  194.     update
  195.     focus -lastfor .t.b2
  196. } {.t}
  197. test focus-1.25 {Tk_FocusCmd procedure} {
  198.     list [catch {focus -unknown} msg] $msg
  199. } {1 {bad option "-unknown": must be -displayof, -force, or -lastfor}}
  200.  
  201. test focus-2.1 {TkFocusFilterEvent procedure} {nonPortable} {
  202.     focus -force .b
  203.     destroy .t
  204.     focusSetup
  205.     update
  206.     set focusInfo {}
  207.     event gen [testwrapper .t] <FocusIn> -detail NotifyAncestor -sendevent 0x54217567
  208.     list $focusInfo
  209. } {{}}
  210. test focus-2.2 {TkFocusFilterEvent procedure} {nonPortable} {
  211.     focus -force .b
  212.     destroy .t
  213.     focusSetup
  214.     update
  215.     set focusInfo {}
  216.     event gen .t <FocusIn> -detail NotifyAncestor -sendevent 0x547321ac
  217.     list $focusInfo [focus]
  218. } {{in .t NotifyAncestor
  219. } .b}
  220. test focus-2.3 {TkFocusFilterEvent procedure} {nonPortable} {
  221.     focus -force .b
  222.     destroy .t
  223.     focusSetup
  224.     update
  225.     set focusInfo {}
  226.     event gen [testwrapper .t] <FocusIn> -detail NotifyAncestor
  227.     update
  228.     list $focusInfo [focus -lastfor .t]
  229. } {{out .b NotifyNonlinear
  230. out . NotifyNonlinearVirtual
  231. in .t NotifyNonlinear
  232. } .t}
  233. test focus-2.4 {TkFocusFilterEvent procedure, FocusIn events} {nonPortable} {
  234.     set result {}
  235.     focus .t.b1
  236.     # Important to end with NotifyAncestor, which is an
  237.     # event that is processed normally. This has a side
  238.     # effect on text 2.5
  239.     foreach detail {NotifyAncestor NotifyNonlinear
  240.         NotifyNonlinearVirtual NotifyPointer NotifyPointerRoot
  241.         NotifyVirtual NotifyAncestor} {
  242.     focus -force .
  243.     update
  244.     event gen [testwrapper .t] <FocusIn> -detail $detail
  245.     set focusInfo {}
  246.     update
  247.     lappend result $focusInfo
  248.     }
  249.     set result
  250. } {{out . NotifyNonlinear
  251. in .t NotifyNonlinearVirtual
  252. in .t.b1 NotifyNonlinear
  253. } {out . NotifyNonlinear
  254. in .t NotifyNonlinearVirtual
  255. in .t.b1 NotifyNonlinear
  256. } {} {out . NotifyNonlinear
  257. in .t NotifyNonlinearVirtual
  258. in .t.b1 NotifyNonlinear
  259. } {} {} {out . NotifyNonlinear
  260. in .t NotifyNonlinearVirtual
  261. in .t.b1 NotifyNonlinear
  262. }}
  263. test focus-2.5 {TkFocusFilterEvent procedure, creating FocusInfo struct} {nonPortable} {
  264.     focusSetup
  265.     focus .t.b1
  266.     update
  267.     event gen [testwrapper .t] <FocusIn> -detail NotifyAncestor
  268.     list $focusInfo [focus]
  269. } {{out . NotifyNonlinear
  270. in .t NotifyNonlinearVirtual
  271. in .t.b1 NotifyNonlinear
  272. } .t.b1}
  273. test focus-2.6 {TkFocusFilterEvent procedure, FocusIn events} {
  274.     focus .t.b1
  275.     focus .
  276.     update
  277.     event gen [testwrapper .t] <FocusIn> -detail NotifyAncestor
  278.     set focusInfo {}
  279.     set x [focus]
  280.     event gen . <KeyPress-x>
  281.     list $x $focusInfo
  282. } {.t.b1 {press .t.b1 x}}
  283. test focus-2.7 {TkFocusFilterEvent procedure, FocusOut events} {
  284.     set result {}
  285.     foreach detail {NotifyAncestor NotifyInferior NotifyNonlinear
  286.         NotifyNonlinearVirtual NotifyPointer NotifyPointerRoot
  287.         NotifyVirtual} {
  288.     focus -force .t.b1
  289.     event gen [testwrapper .t] <FocusOut> -detail $detail
  290.     update
  291.     lappend result [focus]
  292.     }
  293.     set result
  294. } {{} .t.b1 {} {} .t.b1 .t.b1 {}}
  295. test focus-2.8 {TkFocusFilterEvent procedure, FocusOut events} {
  296.     focus -force .t.b1
  297.     event gen .t.b1 <FocusOut> -detail NotifyAncestor
  298.     focus
  299. } {.t.b1}
  300. test focus-2.9 {TkFocusFilterEvent procedure, FocusOut events} {
  301.     focus .t.b1
  302.     event gen [testwrapper .] <FocusOut> -detail NotifyAncestor
  303.     focus
  304. } {}
  305. test focus-2.10 {TkFocusFilterEvent procedure, Enter events} {
  306.     set result {}
  307.     focus .t.b1
  308.     focusClear
  309.     foreach detail {NotifyAncestor NotifyInferior NotifyNonlinear
  310.         NotifyNonlinearVirtual NotifyVirtual} {
  311.     event gen [testwrapper .t] <Enter> -detail $detail -focus 1
  312.     update
  313.     lappend result [focus]
  314.     event gen [testwrapper .t] <Leave> -detail NotifyAncestor
  315.     update
  316.     }
  317.     set result
  318. } {.t.b1 {} .t.b1 .t.b1 .t.b1}
  319. test focus-2.11 {TkFocusFilterEvent procedure, Enter events} {
  320.     focusClear
  321.     set focusInfo {}
  322.     event gen [testwrapper .t] <Enter> -detail NotifyAncestor
  323.     update
  324.     set focusInfo
  325. } {}
  326. test focus-2.12 {TkFocusFilterEvent procedure, Enter events} {
  327.     focus -force .b
  328.     update
  329.     set focusInfo {}
  330.     event gen [testwrapper .t] <Enter> -detail NotifyAncestor -focus 1
  331.     update
  332.     set focusInfo
  333. } {}
  334. test focus-2.13 {TkFocusFilterEvent procedure, Enter events} {
  335.     focus .t.b1
  336.     focusClear
  337.     event gen [testwrapper .t] <Enter> -detail NotifyAncestor -focus 1
  338.     set focusInfo {}
  339.     update
  340.     set focusInfo
  341. } {in .t NotifyVirtual
  342. in .t.b1 NotifyAncestor
  343. }
  344. test focus-2.14 {TkFocusFilterEvent procedure, Enter events, ignore errors when setting focus due to implicit focus} {
  345.     focusClear
  346.     catch {destroy .t2}
  347.     toplevel .t2
  348.     wm withdraw .t2
  349.     update
  350.     set focusInfo {}
  351.     event gen [testwrapper .t2] <Enter> -detail NotifyAncestor -focus 1
  352.     update
  353.     destroy .t2
  354. } {}
  355. test focus-2.15 {TkFocusFilterEvent procedure, Leave events} {
  356.     set result {}
  357.     focus .t.b1
  358.     foreach detail {NotifyAncestor NotifyInferior NotifyNonlinear
  359.         NotifyNonlinearVirtual NotifyVirtual} {
  360.     focusClear
  361.     event gen [testwrapper .t] <Enter> -detail NotifyAncestor -focus 1
  362.     update
  363.     event gen [testwrapper .t] <Leave> -detail $detail
  364.     update
  365.     lappend result [focus]
  366.     }
  367.     set result
  368. } {{} .t.b1 {} {} {}}
  369. test focus-2.16 {TkFocusFilterEvent procedure, Leave events} {
  370.     set result {}
  371.     focus .t.b1
  372.     event gen [testwrapper .t] <Enter> -detail NotifyAncestor -focus 1
  373.     update
  374.     set focusInfo {}
  375.     event gen [testwrapper .t] <Leave> -detail NotifyAncestor
  376.     update
  377.     set focusInfo
  378. } {out .t.b1 NotifyAncestor
  379. out .t NotifyVirtual
  380. }
  381. test focus-2.17 {TkFocusFilterEvent procedure, Leave events} {
  382.     set result {}
  383.     focus .t.b1
  384.     event gen [testwrapper .t] <Enter> -detail NotifyAncestor -focus 1
  385.     update
  386.     set focusInfo {}
  387.     event gen .t.b1 <Leave> -detail NotifyAncestor
  388.     event gen [testwrapper .] <Leave> -detail NotifyAncestor
  389.     update
  390.     list $focusInfo [focus]
  391. } {{out .t.b1 NotifyAncestor
  392. out .t NotifyVirtual
  393. } {}}
  394.  
  395. test focus-3.1 {SetFocus procedure, create record on focus} {
  396.     toplevel .t2 -width 250 -height 100
  397.     wm geometry .t2 +0+0
  398.     update
  399.     focus -force .t2
  400.     update
  401.     focus
  402. } {.t2}
  403. catch {destroy .t2}
  404. # This test produces no result, but it will generate a protocol
  405. # error if Tk forgets to make the window exist before focussing
  406. # on it.
  407. test focus-3.2 {SetFocus procedure, making window exist} {
  408.     update
  409.     button .b2 -text "Another button"
  410.     focus .b2
  411.     update
  412. } {}
  413. catch {destroy .b2}
  414. update
  415. # The following test doesn't produce a check-able result, but if
  416. # there are bugs it may generate an X protocol error.
  417. test focus-3.3 {SetFocus procedure, delaying claim of X focus} {
  418.     focusSetup
  419.     focus -force .t.b2
  420.     update
  421. } {}
  422. test focus-3.4 {SetFocus procedure, delaying claim of X focus} {
  423.     focusSetup
  424.     wm withdraw .t
  425.     focus -force .t.b2
  426.     toplevel .t2 -width 250 -height 100
  427.     wm geometry .t2 +10+10
  428.     focus -force .t2
  429.     wm withdraw .t2
  430.     update
  431.     wm deiconify .t2
  432.     wm deiconify .t
  433. } {}
  434. catch {destroy .t2}
  435. test focus-3.5 {SetFocus procedure, generating events} {
  436.     focusSetup
  437.     focusClear
  438.     set focusInfo {}
  439.     focus -force .t.b2
  440.     update
  441.     set focusInfo
  442. } {in .t NotifyVirtual
  443. in .t.b2 NotifyAncestor
  444. }
  445. test focus-3.6 {SetFocus procedure, generating events} {
  446.     focusSetup
  447.     focus -force .b
  448.     update
  449.     set focusInfo {}
  450.     focus .t.b2
  451.     update
  452.     set focusInfo
  453. } {out .b NotifyNonlinear
  454. out . NotifyNonlinearVirtual
  455. in .t NotifyNonlinearVirtual
  456. in .t.b2 NotifyNonlinear
  457. }
  458. test focus-3.7 {SetFocus procedure, generating events} {nonPortable} {
  459.     # Non-portable because some platforms generate extra events.
  460.  
  461.     focusSetup
  462.     focusClear
  463.     set focusInfo {}
  464.     focus .t.b2
  465.     update
  466.     set focusInfo
  467. } {}
  468.  
  469. test focus-4.1 {TkFocusDeadWindow procedure} {
  470.     focusSetup
  471.     update
  472.     focus -force .b
  473.     update
  474.     destroy .t
  475.     focus
  476. } {.b}
  477. test focus-4.2 {TkFocusDeadWindow procedure} {
  478.     focusSetup
  479.     update
  480.     focus -force .t.b2
  481.     focus .b
  482.     update
  483.     destroy .t.b2
  484.     update
  485.     focus
  486. } {.b}
  487.  
  488. # Non-portable due to wm-specific redirection of input focus when
  489. # windows are deleted:
  490.  
  491. test focus-4.3 {TkFocusDeadWindow procedure} {nonPortable} {
  492.     focusSetup
  493.     update
  494.     focus .t
  495.     update
  496.     destroy .t
  497.     update
  498.     focus
  499. } {}
  500. test focus-4.4 {TkFocusDeadWindow procedure} {
  501.     focusSetup
  502.     focus -force .t.b2
  503.     update
  504.     destroy .t.b2
  505.     focus
  506. } {.t}
  507.  
  508. # I don't know how to test most of the remaining procedures of this file
  509. # explicitly;  they've already been exercised by the preceding tests.
  510.  
  511. test focus-5.1 {ChangeXFocus procedure, don't take focus unless have it} {
  512.     focusSetup
  513.     focus -force .t
  514.     update
  515.     set result [focus]
  516.     send [dobg {tk appname}] {focus -force .; update}
  517.     lappend result [focus]
  518.     focus .t.b2
  519.     update
  520.     lappend result [focus]
  521. } {.t .t {}}
  522.  
  523. catch {destroy .t}
  524. bind all <FocusIn> {}
  525. bind all <FocusOut> {}
  526. bind all <KeyPress> {}
  527. cleanupbg
  528. fixfocus
  529.  
  530. test focus-6.1 {miscellaneous - embedded application in same process} {unixOnly} {
  531.     eval interp delete [interp slaves]
  532.     catch {destroy .t}
  533.     toplevel .t
  534.     wm geometry .t +0+0
  535.     frame .t.f1 -container 1
  536.     frame .t.f2
  537.     pack .t.f1 .t.f2
  538.     entry .t.f2.e1 -bg red
  539.     pack .t.f2.e1
  540.     bind all <FocusIn> {lappend x "focus in %W %d"}
  541.     bind all <FocusOut> {lappend x "focus out %W %d"}
  542.     interp create child
  543.     child eval "set argv {-use [winfo id .t.f1]}"
  544.     load {} tk child
  545.     child eval {
  546.     entry .e1 -bg lightBlue
  547.     pack .e1
  548.     bind all <FocusIn> {lappend x "focus in %W %d"}
  549.     bind all <FocusOut> {lappend x "focus out %W %d"}
  550.     set x {}
  551.     }
  552.  
  553.     # Claim the focus and wait long enough for it to really arrive.
  554.  
  555.     focus -force .t.f2.e1
  556.     after 300 {set timer 1}
  557.     vwait timer
  558.     set x {}
  559.     lappend x [focus] [child eval focus]
  560.  
  561.     # See if a "focus" command will move the focus to the embedded
  562.     # application.
  563.  
  564.     child eval {focus .e1}
  565.     after 300 {set timer 1}
  566.     vwait timer
  567.     lappend x |
  568.     child eval {lappend x |}
  569.  
  570.     # Bring the focus back to the main application.
  571.  
  572.     focus .t.f2.e1
  573.     after 300 {set timer 1}
  574.     vwait timer
  575.     set result [list $x [child eval {set x}]]
  576.     interp delete child
  577.     set result
  578. } {{.t.f2.e1 {} {focus out .t.f2.e1 NotifyNonlinear} {focus out .t.f2 NotifyNonlinearVirtual} {focus in .t.f1 NotifyNonlinear} | {focus out .t.f1 NotifyNonlinear} {focus in .t.f2 NotifyNonlinearVirtual} {focus in .t.f2.e1 NotifyNonlinear}} {{focus in . NotifyVirtual} {focus in .e1 NotifyAncestor} | {focus out .e1 NotifyAncestor} {focus out . NotifyVirtual}}}
  579. test focus-6.2 {miscellaneous - embedded application in different process} {unixOnly} {
  580.     eval interp delete [interp slaves]
  581.     catch {destroy .t}
  582.     setupbg
  583.     toplevel .t
  584.     wm geometry .t +0+0
  585.     frame .t.f1 -container 1
  586.     frame .t.f2
  587.     pack .t.f1 .t.f2
  588.     entry .t.f2.e1 -bg red
  589.     pack .t.f2.e1
  590.     bind all <FocusIn> {lappend x "focus in %W %d"}
  591.     bind all <FocusOut> {lappend x "focus out %W %d"}
  592.     setupbg -use [winfo id .t.f1]
  593.     dobg {
  594.     entry .e1 -bg lightBlue
  595.     pack .e1
  596.     bind all <FocusIn> {lappend x "focus in %W %d"}
  597.     bind all <FocusOut> {lappend x "focus out %W %d"}
  598.     set x {}
  599.     }
  600.  
  601.     # Claim the focus and wait long enough for it to really arrive.
  602.  
  603.     focus -force .t.f2.e1
  604.     after 300 {set timer 1}
  605.     vwait timer
  606.     set x {}
  607.     lappend x [focus] [dobg focus]
  608.  
  609.     # See if a "focus" command will move the focus to the embedded
  610.     # application.
  611.  
  612.     dobg {focus .e1}
  613.     after 300 {set timer 1}
  614.     vwait timer
  615.     lappend x |
  616.     dobg {lappend x |}
  617.  
  618.     # Bring the focus back to the main application.
  619.  
  620.     focus .t.f2.e1
  621.     after 300 {set timer 1}
  622.     vwait timer
  623.     set result [list $x [dobg {set x}]]
  624.     cleanupbg
  625.     set result
  626. } {{.t.f2.e1 {} {focus out .t.f2.e1 NotifyNonlinear} {focus out .t.f2 NotifyNonlinearVirtual} {focus in .t.f1 NotifyNonlinear} | {focus out .t.f1 NotifyNonlinear} {focus in .t.f2 NotifyNonlinearVirtual} {focus in .t.f2.e1 NotifyNonlinear}} {{focus in . NotifyVirtual} {focus in .e1 NotifyAncestor} | {focus out .e1 NotifyAncestor} {focus out . NotifyVirtual}}}
  627.  
  628. eval destroy [winfo children .]
  629. bind all <FocusIn> {}
  630. bind all <FocusOut> {}
  631.